(ns ensemble.primary-stage-test
  (:import javafx.scene.control.Button)
  (:require [clojure.test :refer :all ]
            [ensemble.primary-stage :refer [add-sample-titles]]
            [cljfx.dsl :refer :all ]))

(deftest -test-add-sample-titles
  (testing "add sample titles of a page to a panel"
    (let [pane (tilePane)
          page {:type :category
                :name "root"
                :children [
                            {:type :sample :name "sample1"}
                            {:type :sample :name "sample2"}
                            {:type :sample :name "sample3"}
                            {:type :category :name "sub-category"
                             :children [{:type :sample :name "sample4"}
                                        {:type :sample :name "sample5"}]}
                           ]
                }]
      (add-sample-titles page pane)
      (is (= (count (.getChildren pane)) 5))
      (doseq [child (.getChildren pane)]
        (is (= (class child) Button))
        (is (.startsWith (.getText child) "sample"))))
    ))

(run-tests)
